<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>

<%
	String path = request.getContextPath();
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>字典管理</title>
<link rel="stylesheet" href="<%=path%>/easyui/themes/default/easyui.css"
	type="text/css" media="screen" />
<link rel="stylesheet" href="<%=path%>/easyui/themes/icon.css"
	type="text/css" media="screen" />
<link rel="stylesheet" href="<%=path%>/css/main.css" type="text/css"
	media="screen" />
<link rel="stylesheet" type="text/css" href="../../css/Tooltip.css" />
<script src="<%=path%>/easyui/jquery-1.4.4.min.js"></script>
<script src="<%=path%>/easyui/jquery.easyui.min.js"></script>
<!-- mytab -->
<script src="<%=path%>/myjs/myTab.js"></script>
<!-- sys -->
<script src="<%=path%>/myjs/sys.js"></script>
<script src="<%=path%>/easyui/easyMask.js"></script>
<script src="<%=path%>/easyui/easyUI.js"></script>
<script src="<%=path%>/easyui/easyLayer.js"></script>
<script src="<%=path%>/myjs/dicManager.js"></script>
<script>
var proPath = '<%=path%>';
var dicurl;
var greyLayer ;
var greyLayer1;
var win,form,searchWin,searchForm;
		$(function(){
			$('#fmt').tree({
				url: '<%=path%>/dicManager/getParentDic',//调用菜单的json数据
			checked : true,
			onClick : function(node) {
				dicurl = '<%=path%>'+node.attributes.url;
				$('#p_code').val(node.id);
				dic(node.text, dicurl, node.id);
			}
		});
		$('body').layout();
	});
	function dic(title, url, id) {
		grid = $('#tt1').datagrid(
				{
					title : title,
					// 		iconCls:ics,		
					fit : true,//表格自动填充	
					loadMsg : '正在努力为您加载，请稍作等待…',//加载信息				
					nowrap : false,
					striped : true, //隔行换色
					singleSelect : false,//是否单选
					collapsible : false,
					url : url + "getDics?id=" + id + '&date=' + new Date(),//请求数据
					sortName : 'id', //排序的列
					sortOrder : 'asc', //asc  or  desc
					remoteSort : false, //远程排序
					idField : 'c_seq', //指示该字段是一个标识字段。
					pageNumber : 1, //当前页码
					pageSize:20,
					columns : [ [ {
						field : 'ck',
						checkbox : true
					}, {
						title : '字典序号',
						field : 'c_seq',
						width : 80,
						sortable : true
					} ,{
						field : 'c_code',
						title : '字典Code',
						width : 150,
						sortable : true
					}, {
						field : 'c_name',
						title : '字典value',
						width : 300
					}, {
						field : 'attr',
						title : '属性标识',
						width : 300
					},{
						field : 'is_activeDesc',
						title : '字典状态',
						width : 150
					} ] ],
					pagination : true,//是否显示分页项
					rownumbers : true, //显示行号
					toolbar : [ {
						text : '新增',
						iconCls : 'icon-add',
						handler : function() {
							newDic(dicurl);
						}
					}, '-', {
						text : '修改',
						iconCls : 'icon-edit',
						handler : function() {
							editDic(dicurl);
						}

					}, '-', {
						text : '删除',
						iconCls : 'icon-cancel',
						handler : function() {
							cancelDic(dicurl);
						}

					}, '-', {
						text : '切换字典状态',
						iconCls : 'icon-remove',
						handler : function() {
							delDic(dicurl);
						}
					}, '-', {
						text : '条件查询',
						iconCls : 'icon-search',
						handler : function() {
							searchFormOpen(dicurl);
						}
					} ],
					onLoadSuccess : function() {
						if (grid)
							grid.datagrid('clearSelections');
						//编辑窗口
						$('#btn-save,#btn-cancel,#btn-cancel2').linkbutton();
						win = $('#dic-window').window({
							collapsible : false,
							minimizable : false,
							maximizable : true,
							closable : true,
							onClose : function() {
								greyLayer.close();
							},
							closed : true
						});
						searchWin = $('#search-win').window({
							collapsible : false,
							minimizable : false,
							maximizable : true,
							closable : true,
							onClose : function() {
								greyLayer.close();
							},
							closed : true
						});
						form = win.find('form');
						searchForm = win.find('form');
						//灰显图层
						greyLayer = new easyMask(null, '100%', '100%', 100,
								'#000', 8, true);
						
						
					},
					onLoadError : function() {
						if (grid)
							grid.datagrid('clearSelections');
						//编辑窗口
						$('#btn-save,#btn-cancel').linkbutton();
						win = $('#dic-window').window({
							collapsible : false,
							minimizable : false,
							maximizable : true,
							closable : true,
							onClose : function() {
								greyLayer.close();
							},
							closed : true
						});
						form = win.find('form');
						greyLayer = new easyMask(null, '100%', '100%', 100,
								'#000', 8, true);
					}
				});
		//初始化pagination工具开始
		var pagetool = $('#tt1').datagrid('getPager');
		pagetool.pagination({
			beforePageText : '第',
			afterPageText : '页，共{pages}页',
			displayMsg : '显示从 {from} 到  {to} , 总记录 {total} '
		});
		//初始化pagination工具结束
	}
</script>
</head>
<body>
	<div region="west" title=""
		style="width: 130px; padding1: 1px; overflow: hidden;">
		<ul id="fmt"></ul>
	</div>
	<div region="center" fit="true" style="padding: 5px 135px 5px 5px;">
		<table id="tt1"></table>
	</div>
	<div id="dic-window" title="字典维护" style="width: 350px; height: 240px;">
		<div style="padding: 20px 10px 20px 20px;">
			<style>
				#form table tr td input {
					width: 200px;
				}
			</style>
			<form id='form' method="post">
				<input type="hidden" name="p_code" id="p_code" value="" />
				<input type="hidden" name="c_seq" id="c_seq" value="" />
				<input type="hidden" name="ido" id="ido" value="" />
				<table id='update_table' style='display: none;'>
					<tr>
						<td>字典Code：</td>
						<td><input name="c_code" type="text"
							class="easyui-validatebox" id="c_code" required="true"
							validType="length[1,10]"></input></td>
					</tr>
					<tr>
						<td>字典value：</td>
						<td><input name="c_name" type="text"
							class="easyui-validatebox" id="c_name" required="true"></input></td>
					</tr>
					<tr>
						<td>属性标识：</td>
						<td><input name="attr" type="text"
							class="easyui-validatebox" id="attr" required="true"></input></td>
					</tr>
					<tr>
						<td>是否启用：</td>
						<td><input class="easyui-combobox" name="is_active"
							id="is_active" url="disabled.json" valueField="id"
							textField="text" panelHeight="auto"
							required="true"></input></td>
					</tr>
				</table>
			</form>
		</div>
		<div style="text-align: center; padding: 5px;">
			<a href="javascript:void(0)" onclick="saveDic()" id="btn-save"
				icon="icon-save">确定</a> <a href="javascript:void(0)"
				onclick="closeWindow()" id="btn-cancel" icon="icon-cancel">取消</a>
		</div>
	</div>
	
	<div id="search-win" title="查询条件" style="width: 350px; height: 240px;">
		<div style="padding: 20px 10px 20px 20px;">
			<style>
				#form table tr td input {
					width: 200px;
				}
			</style>
			<form id='searchForm' method="post">
				<input type="hidden" name="p_code" id="s_p_code" value="" />
				<input type="hidden" name="c_seq" id="s_c_seq" value="" />
				<table id='search_table' style='display: none;'>
					<tr>
						<td>字典Code：</td>
						<td><input name="c_code" type="text"
							class="easyui-validatebox" id="s_c_code" 
							validType="length[1,10]"></input></td>
					</tr>
					<tr>
						<td>字典value：</td>
						<td><input name="c_name" type="text"
							class="easyui-validatebox" id="s_c_name" ></input></td>
					</tr>
				</table>
			</form>
		</div>
		<div style="text-align: center; padding: 5px;">
			<a href="javascript:void(0)" onclick="saveDic()" id="btn-save"
				icon="icon-save">确定</a> <a href="javascript:void(0)"
				onclick="closeWindow()" id="btn-cancel2" icon="icon-cancel">取消</a>
		</div>
	</div>
</body>
</html>
